package com.ruoyi.youtian.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.youtian.domain.vo.EarlyWarninVo;
import com.ruoyi.youtian.domain.vo.PieChartVo;
import com.ruoyi.youtian.mapper.EarlyWarninMapper;
import com.ruoyi.youtian.service.EarlyWarninService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EarlyWarninServiceImpl implements EarlyWarninService {


    @Autowired
    private EarlyWarninMapper earlyWarninMapper;

    /**
     * 饼图
     * @param earlyWarninVo
     * @return
     */
    @Override
    public AjaxResult getPieChart(EarlyWarninVo earlyWarninVo) {
        EarlyWarninVo pieChart = earlyWarninMapper.getPieChart(earlyWarninVo);
        if (earlyWarninVo.getId() != null) {
            pieChart.setTypesum("1");
        }
        pieChart.setSceneName(earlyWarninVo.getSceneName());
        return AjaxResult.success(pieChart);
    }
    /**
     * 柱图
     * @param earlyWarninVo
     * @return
     */
    @Override
    public AjaxResult getColumndiagram(EarlyWarninVo earlyWarninVo) {
        List<EarlyWarninVo> pieChartVos = earlyWarninMapper.getColumndiagram();
        for (EarlyWarninVo chartVo : pieChartVos) {
            chartVo.setDev_azdw1_id(earlyWarninVo.getDev_azdw1_id());
            chartVo.setDev_azdw3_id(earlyWarninVo.getDev_azdw3_id());
            chartVo.setDev_azdw2_id(earlyWarninVo.getDev_azdw2_id());
            chartVo.setDev_azdw4_id(earlyWarninVo.getDev_azdw4_id());
            chartVo.setDev_azdw5_id(earlyWarninVo.getDev_azdw5_id());

            EarlyWarninVo pieChart = earlyWarninMapper.getPieChart(chartVo);
            chartVo.setEquipmentsum(pieChart.getEquipmentsum());
            chartVo.setTypesum(pieChart.getTypesum());
            chartVo.setTypesum("1");
        }


        return AjaxResult.success(pieChartVos);
    }

    /**
     * 设备列表
     * @param earlyWarninVo
     * @return
     */
    @Override
    public List<EarlyWarninVo> getEquipmentlist(EarlyWarninVo earlyWarninVo) {
        return earlyWarninMapper.getEquipmentlist(earlyWarninVo);
    }
}
